//
//  ZDCategoryViewController.m
//  1012GiftTips
//
//  Created by Apple on 15/10/15.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZDCategoryViewController.h"
#import "ZDStrategyController.h"
#import "ZDJumpViewController.h"
#import "ZDGiftCategoryViewController.h"

@interface ZDCategoryViewController ()

@property (weak, nonatomic) IBOutlet UISegmentedControl *segment;


@end

@implementation ZDCategoryViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    ZDStrategyController *strategyVc = [[ZDStrategyController alloc] init];
    
    [self addChildViewController:strategyVc];
    
    ZDGiftCategoryViewController *giftVc = [[ZDGiftCategoryViewController alloc] init];
    
    [self addChildViewController:giftVc];
    
    
    //默认选中第一个
    self.segment.selectedSegmentIndex = 0;
    [self segmentClickChangeVc:self.segment];
}

- (IBAction)segmentClickChangeVc:(UISegmentedControl *)sender
{
    for (UIView *view in self.view.subviews)
    {
        [view removeFromSuperview];
    }
    
    if (sender.selectedSegmentIndex == 0)
    {
        ZDStrategyController *vc = self.childViewControllers[0];
        
        vc.view.frame = self.view.bounds;
        
        [self.view addSubview:vc.view];
    }
    else if (sender.selectedSegmentIndex == 1)
    {
        ZDGiftCategoryViewController *vc = self.childViewControllers[1];
        
//        vc.view.backgroundColor = [UIColor greenColor];
        
        vc.view.frame = self.view.bounds;
        
        [self.view addSubview:vc.view];
    }
}



@end
